import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:series_play/comm/base/base_state.dart';
import 'package:series_play/comm/ext/context_ext.dart';

import '../../widget/app_button.dart';
import '../../widget/app_color.dart';
import '../../widget/app_input.dart';
import '../../widget/app_text.dart';
import 'controller/quick_login_controller.dart';

class AccountRegisterPage extends StatefulWidget {
  const AccountRegisterPage({super.key});

  @override
  State<AccountRegisterPage> createState() => _AccountRegisterPageState();
}

class _AccountRegisterPageState
    extends BaseControllerState<AccountRegisterPage, QuickLoginController> {
  @override
  Widget buildPage(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(32).w,
      alignment: Alignment.center,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          // 邮箱
          buildTitle(Icons.email, context.tr.email),
          12.verticalSpace,
          AppInput(
            hint: context.tr.pleaseInputEmail,
            keyboardType: TextInputType.emailAddress,
          ),
          // 验证码
          15.verticalSpace,
          buildTitle(Icons.email, context.tr.verifyCode),
          12.verticalSpace,
          Row(
            children: [
              Expanded(
                flex: 2,
                child: AppInput(
                  hint: context.tr.pleaseInputVerifyCode,
                  keyboardType: TextInputType.number,
                  inputFormatters: [LengthLimitingTextInputFormatter(6)],
                ),
              ),
              11.horizontalSpace,
              Expanded(
                flex: 1,
                child: Container(
                  height: 44.w,
                  decoration: BoxDecoration(
                    color: AppColor.white_20,
                    borderRadius: BorderRadius.circular(4).r,
                  ),
                  alignment: Alignment.center,
                  child: AppText.secondary(
                    context.tr.sendVerifyCode,
                    color: AppColor.white_40,
                  ),
                ),
              ),
            ],
          ),
          // 密码
          15.verticalSpace,
          buildTitle(null, context.tr.password),
          12.verticalSpace,
          AppInput(
            hint: context.tr.pleaseInputPassword,
            obscureText: true,
            keyboardType: TextInputType.visiblePassword,
          ),
          // 重复密码
          15.verticalSpace,
          buildTitle(null, context.tr.reEnterPassword),
          12.verticalSpace,
          AppInput(
            hint: context.tr.pleaseInputPasswordAgain,
            obscureText: true,
            keyboardType: TextInputType.visiblePassword,
          ),

          34.verticalSpace,
          AppButton(
            context.tr.registerAndLogin,
            isGradient: false,
            onTap: () {},
          ),
        ],
      ),
    );
  }

  Widget buildTitle(IconData? icon, String title) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 3).w,
      child: Row(
        children: [
          icon == null
              ? Container()
              : Icon(icon, size: 12.w, color: AppColor.white_40),
          icon == null ? Container() : 7.horizontalSpace,
          AppText.secondary(title, color: AppColor.white_40),
        ],
      ),
    );
  }

  @override
  QuickLoginController createController() {
    return Get.find();
  }

  @override
  bool isFindGetController() {
    return true;
  }
}
